<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\ApiRequest;
use Illuminate\Http\UploadedFile;

/**
 * @property string name
 * @property UploadedFile logo
 * @property string url
 * @property string remark
 * @property int priority
 */
class PartnerStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'     => 'required|string',
            'logo'     => 'required|file',
            'url'      => 'sometimes|url',
            'remark'   => 'sometimes|string',
            'priority' => 'sometimes|numeric|min:0'
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'name.*'     => ':attribute必须是字符串',
            'logo.*'     => ':attribute必须是上传的图片',
            'url.*'      => ':attribute必须是合法的url',
            'remark.*'   => ':attribute必须是字符串',
            'priority.*' => ':attribute必须是数值'
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
            'name'     => '合作伙伴名称',
            'logo'     => '上传的图片',
            'url'      => '跳转链接',
            'remark'   => '备注',
            'priority' => '排序',
        ];
    }
}
